
import request from '@/utils/request.js'

export const getCommets = (articleId, offset) => {
  return request({
    method: 'GET',
    url: '/v1_0/comments',
    params: {
      type: 'a', // a表示对文章的评论 ,c表示对评论的回复
      source: articleId,
      offset
    }
  })
}
/**
 * 对文章进行评论
 * @param {*} articleId 文章编号
 * @param {*} content 评论内容
 */
export const addComment = (articleId, content) => {
  return request({
    method: 'POST',
    url: '/v1_0/comments',
    data: {
      target: articleId,
      content
    }
  })
}
/**
 * 对文章评论进行点赞
 * @param {*} commentId 评论id
 */
export const addCommentLike = commentId => {
  return request({
    method: 'POST',
    url: '/v1_0/comment/likings',
    data: {
      target: commentId
    }
  })
}

/**
 * 取消文章评论的点赞
 * @param {*} commentId 评论id
 */
export const deleteCommentLike = commentId => {
  return request({
    method: 'DELETE',
    url: `/v1_0/comment/likings/${commentId}`
  })
}
